package friend

import (
	"api/pb/friend"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateApplyLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateApplyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateApplyLogic {
	return &UpdateApplyLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// UpdateApply 更新申请状态
func (l *UpdateApplyLogic) UpdateApply(req *types.ApplyInfoRequest) (resp *types.Empty, err error) {
	_, err = l.svcCtx.FriendRPC.UpdateApply(l.ctx, &friend.ApplyInfo{Id: req.ID, Status: req.Status})
	if err != nil {
		return nil, err
	}
	return &types.Empty{}, nil
}
